/**
 * 
 */
package com.unsanctioned.radioagregator.utils;

import com.unsanctioned.radioaggregator.R;
import com.unsanctioned.radioagregator.datatypes.RadioStation;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @author wizard
 * This class helps developer to create simple UI.
 */
public class RadioUiUtils {
	public static AlertDialog getRadioInfo(Context context, RadioStation station) {
		View view = LayoutInflater.from(context).inflate(R.layout.radio_info_popup, null);
		if (view != null) {
			((ImageView) view.findViewById(R.id.radio_info_logo)).setImageURI(Uri.parse(station.getLogoUri()));
			((TextView) view.findViewById(R.id.radio_info_name)).setText(station.getName());
			((TextView) view.findViewById(R.id.radio_info_website)).setText(station.getWebsite());
			((TextView) view.findViewById(R.id.radio_info_facebook)).setText(station.getFacebook());
			((TextView) view.findViewById(R.id.radio_info_twitter)).setText(station.getTwitter());
			return new AlertDialog.Builder(context)
			.setNeutralButton("Close", new DialogInterface.OnClickListener() {	
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// TODO Auto-generated method stub
					dialog.dismiss();
				}
			}).setPositiveButton("Map", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// TODO Auto-generated method stub
					
				}
			}).setView(view).create();
		} else {
			return null;
		}
	}
	public static View getRadioListElement(Context context, RadioStation station) {
		View view = LayoutInflater.from(context).inflate(R.layout.radio_station, null);
		if (view != null) {
			((TextView) view.findViewById(R.id.radio_name)).setText(station.getName());
			((ImageView) view.findViewById(R.id.radio_logo)).setImageURI(Uri.parse(station.getLogoUri()));
			return view;
		} else {
			return null;
		}
	}
}
